<div class="padding">
    <div class="toolbar f14 mt25 clearfix">
        <div class="toolbar-tab fl">
            <ul>
                <li  ng-class="{'toolbar-tab-on': autoReply.replyType=='welcome'}">
                    <a href="javascript:;" ng-click="autoReply.changReplyType('welcome')">被添加自动回复</a>
                </li>
                <li ng-class="{'toolbar-tab-on':autoReply.replyType=='autoreply'}">
                    <a href="javascript:;" ng-click="autoReply.changReplyType('autoreply')">消息自动回复</a>
                </li>
                <li ng-class="{'toolbar-tab-on':autoReply.replyType=='keyword'}">
                    <a href="javascript:;" ng-click="autoReply.changReplyType('keyword')">关键词自动回复</a>
                </li>
            </ul>
        </div>
    </div>
    <div ng-if="autoReply.replyType!='keyword'">
        <div send-tab></div>

        <div style="margin-top:25px;">
            <button type="button" class="btn-pr ok-btn" ng-click="autoReply.save()">保存</button>&nbsp;&nbsp;
            <button type="button" class="btn-pr cancel-btn disabled-btn" ng-click="resetContent()">清除内容</button>
        </div>
    </div>


    <div class="keyword-wrap" ng-if="autoReply.replyType=='keyword'">
        <a href="javascript:;" class="btn-add add-rule" style="margin-bottom:15px;" ng-click="autoReply.addRuleInfo()">
            <span class="glyphicon glyphicon-plus"></span><span>添加规则</span>
        </a>
        <div class="keyword_rules">
            <div class="keyword-rule" ng-repeat="rule in autoReply.ruleList">
                <form name="keywordForm">
                    <div class="panel panel-default panel-reset panel-rule dropdown_opened">
                    <div class="panel-heading clearfix"> {{rule.name?rule.name:'新规则'}}
                        <a href="javascript:void(0);" class="icon_dropdown_switch pull-right" >
                            <i class="arrow arrow_up" ng-show="!rule.edit" ng-click="autoReply.editRule(rule)"></i>
                            <i class="arrow arrow_down show" ng-show="rule.edit" ng-click="rule.edit=false"></i>
                        </a>
                    </div>
                    <div class="rule-view show" ng-show="!rule.edit">
                        <div class="keywords clearfix">
                            <label>关键词</label>
                            <ul class="label-content">
                                <li ng-repeat="keyword in rule.keyword_data">{{keyword.keyword}}</li>
                            </ul>
                        </div>
                        <div class="replys clearfix">
                            <label>回复</label>
                            <div class="label-content">{{rule.type}}</div>
                        </div>
                    </div>
                    <div class="rule-edit" ng-if="rule.edit">
                        <div class="rule-name-wrap clearfix">
                            <label><span class="icon-point"></span>规则名</label>
                            <div class="rule-name form">
                                <input type="text" class="form-control rulename-input" name="name" required maxlength="60" ng-model="rule.name">
                                <p class="color-gray">规则名最多60个字</p>
                                <div ng-messages="keywordForm.name.$error"
                                     ng-show="keywordForm.$submitted || keywordForm.name.$touched">
                                    <p class="error" ng-message="required">输入框内容不能为空</p>
                                    <p class="error" ng-message="maxlength">规则名最多60个字</p>
                                </div>
                            </div>
                        </div>
                        <div class="rule-keyword-wrap">
                            <div class="rule-keyword-title clearfix">
                                <label><span class="icon-point"></span>关键字</label>
                                <a href="javascript:;" class="pull-right add-keyword"
                                   ui-dialog="添加关键字"
                                   ui-dialog-ok="autoReply.addWord($dialogScope,$data)"
                                   ui-dialog-cache="false"
                                   ui-dialog-url="business_modules/auto_reply/ngviews/dialog_content.html">添加关键字</a>
                            </div>
                            <ul class="rule-keyword-list">
                                <li class="clearfix" ng-repeat="keyword in rule.keyword_data">
                                    <span class="keyword-name">{{keyword.keyword}}</span>
                                    <div class="pull-right">
                                        <a href="javascript:;" class="align-m match-link" data-index="0" ng-click="keyword.is_exact=keyword.is_exact?0:1">{{keyword.is_exact == 1 ?'全匹配':'未全匹配'}}</a>&nbsp;&nbsp;&nbsp;&nbsp;
                                        <span class="icon-merge icon-edit" data-index="0"
                                              ui-dialog="修改关键字"
                                              ui-dialog-data="keyword"
                                              ui-dialog-ok="autoReply.updateWord($dialogScope,$data)"
                                              ui-dialog-cache="false"
                                              ui-dialog-url="business_modules/auto_reply/ngviews/dialog_content.html"></span>&nbsp;&nbsp;&nbsp;
                                        <span class="icon-merge icon-delete" data-index="0" style="vertical-align:top" ng-click="rule.keyword_data.splice($index,1)"></span>
                                    </div>
                                </li>
                            </ul>
                            <div ng-show="keywordForm.$submitted && rule.keyword_data==0" style="padding: 10px 0 10px 16px;">
                                <p class="error">至少输入一个关键字</p>
                            </div>
                        </div>
                        <div class="rule-reply-wrap">
                            <div class="rule-reply-title">
                                <label><span class="icon-point"></span>回复</label>
                            </div>
                            <div class="weixinEdition"><div class="msg_sender" style="border: none;">
                                <div send-tab="init" ></div>
                            </div>
                            </div>
                        </div>
                        <div class="rule-btns align-r">
                            <button type="button" class="btn-pr ok-btn save-rule" ng-click="autoReply.saveRule(rule,keywordForm)">保存</button>&nbsp;
                            <button type="button" class="btn-pr sub-btn delete-rule" ng-click="autoReply.deleteRule($index,rule)">删除</button>
                        </div>
                    </div>
                </div>
                </form>
            </div>
        </div>
    </div>
</div>